import request from '@/utils/request';
const basePath = '/appsys/oauth2/OAuth2Rest';
import type { BaseBeanModel, ResponsePageData, QueryParamModel, ResponseBaseData } from '@/api/model/baseModel';
export interface SysAuthorizationDto extends BaseBeanModel {
  /** 名称 */
  clientName?: string;
  /** clientId(鼠标点击复制) */
  clientId?: string;
  /** clientSecret(鼠标点击复制) */
  clientSecret?: string;
  /** 授权服务 */
  scope?: string;
  /** 用途 */
  clientDesc?: string;
}

/**
 * 获取分页数据
 * @param param QueryParamModel
 * @returns 列表数据
 */
export function listSysAuthorizationByPage(param: QueryParamModel): Promise<ResponsePageData<SysAuthorizationDto>> {
  return request.post(`${basePath}/searchByPage/v1`, param);
}

/**
 * 根据id加载表单数据
 * @param clientId 表单clientId
 * @returns 该行主表信息
 */
export function getSysAuthorization(clientId: string): Promise<ResponseBaseData<any>> {
  return request.get(`${basePath}/get/v1/${clientId}?`);
}

/**
 * 添加-保存数据
 * @param form SysAuthorizationDto
 * @returns 新增数据
 */
export function saveSysAuthorization(form: SysAuthorizationDto): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/add/v1`, form);
}

/**
 * 编辑-保存数据
 * @param id 表单clientId
 * @param form SysAuthorizationDto
 * @returns 修改后的主表信息
 */
export function editSysAuthorization(id: string, form: SysAuthorizationDto): Promise<ResponseBaseData<any>> {
  return request.put(`${basePath}/edit/v1/${id}`, form);
}

/**
 * 根据id删除数据
 * @param id 表单clientId
 * @returns 删除成功或失败的结果
 */
export function delSysAuthorization(id: string) {
  return request.delete(`${basePath}/delete/v1/${id}`);
}
